package com.ysd.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysd.common.utils.PageUtils;
import com.ysd.modules.sys.dao.CourseDao;
import com.ysd.modules.sys.entity.CourseEntity;
import com.ysd.modules.sys.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("courseService")
public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> implements CourseService {

	@Autowired
	CourseDao courseDao;
	
    /**
     *自定义分页查询
     */
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
    	int page =Integer.parseInt(params.get("page").toString()); 
    	int limit =Integer.parseInt(params.get("limit").toString()); 
    	 Page<CourseEntity> pageInfo = new Page<CourseEntity>(page,limit);
    	 
    	String name=params.get("username").toString();

		QueryWrapper wrapper = new QueryWrapper();
		wrapper.like("name", name);
		return new PageUtils(this.page(pageInfo, wrapper));
  //      return new PageUtils(courseDao.getAllCoure(name, pageInfo));
    }

	@Override
	public List<CourseEntity> getAllCourses() {
		// TODO Auto-generated method stub
		 return baseMapper.selectList(new QueryWrapper<CourseEntity>().eq("status", 0));
	}
    
    
    
 
}